<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件

/**
 * 路由注册部分
 */
\think\Route::domain(\think\Env::get('common.w'), 'app');
\think\Route::domain(\think\Env::get('common.m'), 'admin');


/**
 * 接口返回数据
 * @param $data
 * @param $info
 * @param bool $status
 */
function ret( $data,$info,$status = false)
{
    $d = array(
        'data' => $data,
        'info'   => $info ,
        'status'   => $status ,
    );

    if ( !headers_sent() ){
        header( 'Access-Control-Allow-Origin: *' );
        header( 'Content-Type:application/json;charset=utf-8;' );
    }
    echo json_encode( $d );
    die;
}


/**
 * 生成一个唯一的ID号
 */
function uuid($prefix = 'id')
{
    $str = md5(uniqid($prefix, true));
    return $str;
}